package ru.stepuk.modern.distributions;

import ru.stepuk.modern.generators.RandomNumberGenerator;

/**
 *
 * @author ivan
 */
public class ExponentialDistribution implements Distribution {

    private double rate;
    private RandomNumberGenerator g;

    public ExponentialDistribution(RandomNumberGenerator g, double rate) {
        this.rate = rate;
        this.g = g;
    }

    public double nextValue() {
        return -Math.log(1 - g.nextValue()) / rate;
    }

    public double getRate() {
        return rate;
    }

    @Override
    public String toString() {
        return "exp";
    }
}
